
//
//  DisplayPictureViewController.m
//  PorjectA
//
//  Created by zhilianhe on 15/12/10.
//  Copyright © 2015年 zhilianhe. All rights reserved.
//

#import "DisplayPictureViewController.h"

#define Kwidth self.view.frame.size.width
#define Kheitht self.view.frame.size.height

@interface DisplayPictureViewController ()
@property (nonatomic,retain) UIImageView *imageViewPicture;
@end

@implementation DisplayPictureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    // Do any additional setup after loading the view.
    
    UITapGestureRecognizer *tapView= [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buttonActon:)];
    tapView.numberOfTapsRequired = 1;
    self.view.userInteractionEnabled = YES;
    [self.view addGestureRecognizer:tapView];
    
    
    UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buttonActon:)];
      tapAction.numberOfTapsRequired = 1;
   
  
    
    
    self.imageViewPicture = [[UIImageView alloc]initWithFrame:CGRectMake(0, Kheitht * 0.25, Kwidth, Kheitht * 0.45)];
    self.imageViewPicture.contentMode = UIViewContentModeScaleAspectFill;
    self.imageViewPicture.clipsToBounds = YES;
    [self.imageViewPicture sd_setImageWithURL:[NSURL URLWithString:self.stringUrl] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    
    self.imageViewPicture.userInteractionEnabled = YES;
    [self.view addSubview:self.imageViewPicture];
    
    [self.imageViewPicture addGestureRecognizer:tapAction];
    
    
    
//    UIButton *buttonAction = [UIButton buttonWithType:UIButtonTypeCustom];
//    [buttonAction setImage:[UIImage imageNamed:@"BackIndicator"] forState:UIControlStateNormal];
//    buttonAction.frame = CGRectMake(Kwidth * 0.8, Kheitht * 0.8, Kwidth * 0.1, Kwidth * 0.1);
//    [buttonAction addTarget:self action:@selector(buttonActon:) forControlEvents:UIControlEventTouchUpInside];
//
//    buttonAction.layer.cornerRadius = Kwidth * 0.05;
//    buttonAction.layer.masksToBounds = YES;
//    [self.view addSubview:buttonAction];
    
    
    UIButton *buttonSavePicture = [UIButton buttonWithType:UIButtonTypeCustom];
    [buttonSavePicture setImage:[UIImage imageNamed:@"SavePicture"] forState:UIControlStateNormal];
    [buttonSavePicture addTarget:self action:@selector(buttonSavePicture:) forControlEvents:UIControlEventTouchUpInside];
    buttonSavePicture.frame = CGRectMake(Kwidth * 0.8, Kheitht * 0.8 + Kwidth * 0.1, Kwidth * 0.1, Kwidth * 0.1);
    [self.view addSubview:buttonSavePicture];
//
    
}
-(void)buttonActon:(UITapGestureRecognizer *)button{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
-(void)buttonSavePicture:(UIButton *)button{
//    self.imageViewPicture.image
    
#warning KVNProgress -- MBHUD
//    [KVNProgress showSuccessWithCompletion:^{
//        UIImageWriteToSavedPhotosAlbum(self.imageViewPicture.image, nil, nil, nil);
//    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
